package encaps.utils.rendering;

import encaps.resources.Response;
import encaps.utils.html.HTML;
import encaps.utils.html.HTMLElement;
import org.jdom.Element;

public class HeaderFactory implements FieldFactory {

    public static final String HTML_HEADER_TAG = HTML.H2;

    @Override
    public HTMLElement renderField(Element e, boolean edit) {
        HTMLElement header = new HTMLElement(HTML_HEADER_TAG);
        String value = e.getChildTextTrim(Response.LABEL);
        header.addContent(value);
        return header;
    }

    public static HTMLElement renderHeader(String text) {
        HTMLElement header = new HTMLElement(HTML_HEADER_TAG);
        header.addContent(text);
        return header;
    }
}
